<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$this->title;?></title>
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl?>/public/css/ext-all.css" />
<script type="text/javascript" src="<?=$this->baseUrl?>/public/js/ext-base.js"></script>
<script type="text/javascript" src="<?=$this->baseUrl?>/public/js/ext-all.js"></script>
</head>
<script type="text/javascript">
Ext.QuickTips.init();
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());	
var cp = new Ext.state.CookieProvider();
Ext.state.Manager.setProvider(cp);
var cssname = cp.get("style");	
Ext.util.CSS.swapStyleSheet("theme","<?=$this->baseUrl?>/public/css/"+cssname);
Ext.onReady(function()
{
LoginWindow=Ext.extend(Ext.Window,{
title : '登陆plima系统',       
width : 300,           
height : 200,       
collapsible : true,
defaults : {           
border : false
},
stateful:true,
stateId:'window.login',
bodyStyle:"padding:10px",
buttonAlign : 'center',   
createFormPanel :function() {
return new Ext.form.FormPanel( {
bodyStyle : 'padding-top:6px',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 55,
labelPad : 0,
frame : true,
defaults : {
allowBlank : false,
width : 158
},
items : [{
cls : 'user',
name : 'username',
fieldLabel : '帐号',
blankText : '帐号不能为空'
}, {
cls : 'key',
name : 'password',
fieldLabel : '密码',
blankText : '密码不能为空',
inputType : 'password'
}, {
cls : 'key',
name:'imgcode',
id:'randCode',
fieldLabel:'验证码',
width:100,
blankText : '验证码不能为空'
}]
});
},   
keys:[{
	  key:[10,13],
	  fn:fn_login
	  }],
login:function() {
					 if(this.fp.getForm().isValid()){
					 this.fp.getForm().submit({
							waitTitle: '提示',
							waitMsg:'waiting',
							url:'<?=$this->baseUrl?>/index/login',
							method:'post',
							success:function(form,action){
								var temp=Ext.util.JSON.decode(action.response.responseText);								
								window.location.href='<?=$this->baseUrl?>/index/main';
								},
							failure:function(form,action){
								var temp=Ext.util.JSON.decode(action.response.responseText);
								Ext.MessageBox.show({title:'警告',
													msg:"<strong>错误信息:"+temp.msg+"</strong>",
													buttons:Ext.MessageBox.OK,
													animEl:'randCode',
													icon:Ext.MessageBox.ERROR});								
								}
							});
					 }
				 },
initComponent : function(){
LoginWindow.superclass.initComponent.call(this);      
this.fp=this.createFormPanel();
this.add(this.fp);
this.addButton('登陆',this.login,this);
this.addButton('重置', function(){this.fp.form.reset();},this);
}    
});

function fn_login(){
	win.login();
	}

var win=new LoginWindow();

win.show();
var bd = Ext.getDom('randCode');  
var bd2 = Ext.get(bd.parentNode); 
//bd2.createChild({tag: 'img', src: '<?=$this->baseUrl?>/index/imgcode',align:'absbottom',id:'imgcode',alt:'点击刷新',title:'点击刷新'}); 
 bd2.createChild([{
        tag: 'span',
        html: '<a href="javascript:reloadcode();">'
    }, {
        tag: 'img',
        id: 'safecode',
        src: '<?=$this->baseUrl?>/index/imgcode',
        align: 'absbottom'
    }, {
        tag: 'span',
        html: '</a>'
    }]);
 

}
);
function reloadcode(){
	 var checkcode = document.getElementById("safecode");
	var dt = new Date();	
	checkcode.setAttribute("src","<?=$this->baseUrl?>/index/imgcode/t="+dt);
	 }

</script>

<body>
<div id='form-ct'></div>
</body>
</html>
